import numpy as np

# 一维数组切片
data = np.array([1,2,3,4,5])
print("原始数据:")
print(data)
print("取头尾中间的数字:")
print(data[1:4])

# 多维数组切片
data1 = [1,2,3,4,5]
data2 = [6,7,8,9,10]
data3 = [11,12,13,14,15]
data4 = [16,17,18,19,20]
data5 = [21,22,23,24,25]
data6 = [26,27,28,29,30]
data = np.array([[data1,data2,data3],[data4,data5,data6]]) # 创建三维数组
print("原始数据:")
print(data)
# 行切片
print("前两行:")
print(data[0:1,0:2]) #取前两行
# 列切片
print("前两列:")
print(data[:,:,0:2]) # 取前两列